import React from 'react';
import classNames from 'classnames';

import {
  Modal,
  Button
} from 'react-bootstrap';

import { default as DialogUnSignNormal } from './dialog/DialogUnSignNormal';
import { product as ProductConfig } from '../config/Common';

class DialogUnSign extends React.Component {

  constructor() {
    super();
  }

  static propTypes = {
    product : React.PropTypes.object,
    user : React.PropTypes.object
  }

  static defaultProps = {
    
  }
  
  getDialogComponent(){

    let { product, user,  productAction, onHide } = this.props;

    let dialogHeader, dialogContent, dialogButton;

    if (!product || !user) {
      return {dialogHeader, dialogContent, dialogButton};
    }

    dialogHeader = `您确认取消关注策略：${product.name}？`;
    dialogContent = <DialogUnSignNormal />
    dialogButton = [{
         text : "确认",
         style : "info",
         callback : function(){
            onHide();
            setTimeout(function(){
                productAction.UnSignProduct(product.gsid);
            }.bind(this),100);
         }
      },{
         text : "取消",
         style : "default"
    }];
    
    return {dialogHeader, dialogContent, dialogButton};
  }

  render() {

    let { onHide,  visiable, ...other} = this.props;

    let { dialogHeader, dialogContent, dialogButton } = this.getDialogComponent();

    return (
        <Modal show={visiable} onHide = { onHide } {...other}>
          <Modal.Header>
            <Modal.Title>
                { dialogHeader }
            </Modal.Title>
          </Modal.Header>
          <Modal.Body>
            {dialogContent}
          </Modal.Body>
          <Modal.Footer>

            { dialogButton && dialogButton.map((button, index) => {
                let callback = (button.callback || onHide).bind(this);
                let bzStyle = button.style || "info";
                return (
                  <Button onClick={ callback } bsStyle={ bzStyle } key={index}>
                    { button.text }
                  </Button>  
                );
            })}
            
          </Modal.Footer>
        </Modal>
    );
  }
}

export default DialogUnSign;
